package com.ruoyi.file.service.storage.impl.aliyun;

import com.ruoyi.file.domain.SysStorageConfig;
import com.ruoyi.file.enums.StorageTypeEnum;
import com.ruoyi.file.service.storage.base.BaseS3StorageServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 阿里云OSS存储服务实现
 * 
 * @author ruoyi
 */
@Slf4j
@Service("aliyunOssStorageService")
public class AliyunOssStorageServiceImpl extends BaseS3StorageServiceImpl {

    @Override
    protected StorageTypeEnum getStorageType() {
        return StorageTypeEnum.ALIYUN;
    }

    @Override
    public boolean shouldUsePathStyle() {
        return false; // 阿里云OSS 使用虚拟主机风格
    }

    @Override
    protected boolean shouldSetContentType() {
        return false; // 阿里云OSS 不设置content-type以避免签名不匹配
    }

    @Override
    protected String buildFileUrl(String protocol, String endpoint, String bucketName, String filePath, StorageTypeEnum storageType) {
        // 阿里云OSS使用虚拟主机风格: bucket.endpoint/filePath
        return String.format("%s://%s.%s/%s", protocol, bucketName, endpoint, filePath);
    }

}
